Refactored js code and merged to the master

probably should remove the unused reject input args