Debug. Fixed infinite loop