integration of codes & working opacity function