cleaned up code organization