rewritten for database instead of html