Wondering if it is the right way or not usually means you have little or no plan. Did you decide how to solve the problem before writing code?
What step are you on in the solution? It looks ok (with...