refactors code