cleaned up code a bit with JSHint