fixed db, refactored index and home pages to use database