I don't understand what is being done here. In any case the name of the function correctType should be changed by something more meaningful like 'typeFilter'