refactor and decrease function complexity
Merge branch 'release/v0.13.3' into develop