Inlined logic to eliminate temporary var