There is some code in the archives which uses blitz collisions and will always produce the correct response .. In fact this would be perfect for you ..
http://www.blitzbasic.com/codearcs/codearcs.php?code=898
http://www.blitzbasic.com/codearcs/codearcs.php?code=898