corner cases fixes