added bottom check to visibility test