added logic for validation