Added comments
Added more error checking to the input