Updated validations and separated custom js logic