removed assignment inside if, made use of Optional.