Fix fatal error when creating view