a litle bit of refactoring