added comments, basic error handling, and basic computations