added validator
optimized code, added validators, compared value before entering it to DB