cleaned up code for first implementation