Added JSDoc header to js-file and added more validity checks