cleaned up code and verified