Replaced null check with isPresent.