Trying to fix infinit loop issue