Refactor source codes