refactoring ajax functionality for new measurement option