Trying to improve performance, but some unknown bug