Cleaned up code using JSHint