Modified to use new sleep algorithm