second problem completed and cleaned up the comments