organizing code a bit