refactor inline some code