made some small improvements in the speed