re-implement lab 2a and pass all tests