Added eric's code. Adding sample support