Made better use of API for sample