fixing some performance issues