organizing the code a bit