did some profiling to improve speed