Removed unused 'when' function