Fixed delete problem and added logic for email index