Improve sample code