Now fully functional with database