this seems to work 90% of the time