Corrected the logic to match katja's wishes