Fixed the timeout functionality