fixed error-checkign code in custom.js
added some more content to error messages
cleaned up code in custom.js