refactors a bit more