Refactoring validation code

Change-Id: I6490657e53c1fbd0edf0c0a9a1bff2f87f1622c5