Tip:
When you aren't using complex tables, that is, if you just have a list of items in a table you want to recurse like
table_list = { a,b,c,d,e,f,g,h }
Lua handles the 'ipairs' more efficiently than 'pairs'
for _,item in ipairs( table_list ) do
-- do something with item
end
As for why printmessage twice, is it the exact same both times, not a different message, one from each of two of your three hooks?