needs to be refactored