proper way of doing validation