Fixed delete bug. Moved add command code to a method