fixing infinit loop problem and a path problem