added preprocessing code