Working jquery refactor