Improving addObj function