added recursive call in boundary collision to deal with corner situations