slight refactor, too messy