added insertion operator and fixed errors