use string buffer to implement the code