Edited the addObject function a little bit.