almost there with table detection thanks to book