rewrite code to fix indent issue