changed some things to improve the performance