first version of code, no comments, error checks