Tried to clean-up code a bit