fixes proposed by Magomogo to increase speed