fixed the code and cleaned up even more