joe's code using common db