add timeout command and code cleanup