refactor class into some methods.