Added toString method and fixed bug with counting