cleared up code and changed timeout behavior