clean code
memory optimized