Added an end condition for levels