Improve withinInteractionLimit function

I think that this fixes it.