fix bugs in some methods
refactor methods