The purpose main purpose of this refactoring is to reduce the nested if complexity by adding returning statements instead. This made the readability better and the code more maintainable.