some code rafactoring