refactored by gus