changed compiling and cleaned up code