make db not global
better history control