Adding complete validation logic