Refactored: separated a big method to several smaller methods.
Refactored: extracted a small method.
Refactored: extracted instanceof checking method.
Refactored: removed redundant parameters.
Refactored: removed redundant local parameters and formatted.
Refactored: improved nest levels.
Refactored: separated helper to a independent class.
Refactored: removed unused parameter.