Simplifying code, adjusting, rename variables and adjust indenting