added viewport check