js function for command and validator