trying to cleanup the code, but perf decreased
More cleanup