factorizin some code