Refactiring. Extracted some methods.