As usual, step by step, smaller helper functions are in place.