added function to remove orphans from otable but it's not working yet because of problems comparing dates