mostly working
better last page detection