messy refactor :/