refactored to use wp ajax api