Made subroutines of collision functions.