Refuctor channel related db functions