fixed bug with determing correct viewport