Working version with templates
Fixed FOut records for scanning