You’re probably looking for a more sophisticated solution but it might be worth looking at this old thread.