Code for checking collision almost done, should be quite fast