refining database stuff