more database function and testing