This is done using a pretty terribad hack, introducing an extra function parameter and some code duplication. Unfortunately, there seem to be few alternatives.