added validation
final version