added logic to determine if level is completed