Update perform.js

Fixed the error handling. (Added error branch and modified)