Added some error messages and added check for main methoid