Handling null correctly when wrapping function in SAM wrapper