fixed endless loops