Removed main method, added exception handling