The object type was checked twice unnecessarily. Also use a function for the check to be more explicit.