really needs refactored