added a while-loop