Added time check function to stop search