added php function to clean up database