organized code a bit