changed several things to improve performance