reformat loop
add a couple of hooks