database function or class, to improve