fix compile task, refactor code