added the logging time varaible and put that time wait in main loop if there is some error detected