add function to call a function with a timeout