Resolved variable scope in if block statement