Refactored using jquery