implement MyString.calculate (not so pretty)