distance = 0 checking is added