refactored and handled some extra cases