refactored into code that makes sense