Also, this function needs some docs about the theory.