fixed performance problems I think