Why is this code duplicated here?