fix bug and implement some methods