Fixed bug on validation logic