Added check for empty object