cleaning input and recursive role acquisition