Fixed bug in collision detector