refactored within jquery