bugfixing and still the infinite loop