added support for tables with or without thead element