updated input sample iterator on suggestion of nathanic