improve validation in js