fix and optimization