Moving collision to states and refactoring duplications