implemented a working grayscale algorithm