normalize and optimize