updated to take db variable