Ok, we really need to extract this dirty piece of code into a separate class