improve database operation helper