fixed method-complexity smell
fixed duplication smell