Returning result right away
C# implementation by Jarosław Kroczek