more split and cleanup. Db functions are reduced