Updated to provide validation
Minor efficiency updates and adding validations