added some main methods and error reporting