refactor for ajax and scoring