made some imporovments to speed