Seems like the basic idea. Not sure what language that is but the idea looks about right