move database calls out of junk