refactored for better overview