refactors working