Refactoring compiling function.