toString method and bug fix