better logic fix