added viewport detection