Fix the bug for collsion detection