refactored collision method and branched it to several methods.