Refactored promises, updated jquery