added gradient code