minor fixes. expanded 'add' function