Removed the resultToImage Function as it doesnt work