Added auto-detection of input format