Refactor codes for pseudo