removed bug that occured on averaging of images.