wrote ambient correction code