refactoring all around and brand-new errors