Moved two bits of code into go routines for performance