Refactor codes. Move some methods into parent class which can be reused.