Refactor compilePost