refactor if compile()
some more refactoring