add error checks all over the place, make indentation consistent, make output consistent