better shadow handling for first and last pages