refactored part of jquery