refactor mechanism codes