Updated jacascript to handle deletes for elegantly