some logic fix