organized the code a little better