split up code into sperate files and added functionality