clean code and optimization