Modified the main method to print better error messages