Also try to explain to me what the code exactly does - I'm having a hard time figuring it out.
We might need to make the two cases more clear (this seems to be required related).