fix corner cases