Added set-up logic and some validations
Small additions for error handling