updated to work with separate db