refactored and validated version: Blue team