finally working
implemented validation