fix bugs s1-s4
refactoring 2nd
refactoring
refactoring