UPDATE: Implementation of the solution