Fixed bug on some strange cases