basic criteria met, really needs refactoring though