changed to use database