changing err to object