commented my code and but it in a more logical order.