Remove isValid function and unncessary line of codes