did some refactoring with jQuery