fixing some corner cases