cleaned up code a bit for review