fix infinate loop