Speed improvement, moved data manipulation out of excel