Fixed logical error which made the last item never be the active one