improved csv checking routine and debug strings