adds an optional timeout to the leader and machines function