Added viewport detection