bug logic fixed