Add timeout functionality to sample program