bugfix: end condition fix