started cleaning up the code