thread-last rewrite