generalized the detection and skipping part in the preparse