Final optimized, clean code