organized the code a bit more