Update perform.js

added error checking