refactored to add else clause