invokes a function if it's taking too long