clean code, and optimize MySQL queries if needed