Addressed comment - use tap and block instead of storing the value and returning it after the if.
Addressed comment: Added missing if around warning.