refactoring some extra code