fixed logic for switching levels