Fixed main method, added error method