added ability to override max wait time