organized the code better after it got messed up from splitting in 2 source files