Re factoring and some validation