changed everything to database instead of sql