fixed edit and delete functions (grouping by site id)