preprocessor code refactored