added validation and also contract refresh