Changed logic to be more explicit