fixing crashes in add method