updated gradient comparison and paint exception