cleaned up code a bit for code review