bug fix, added validation