added level finish logic