reorganization of code & modification of collision method