abit of refactoring