refactoring js for new computation form