changed the main and fixed errors