minor logic fixes