organized code a little