compacted sample code