speeding the code up a bit