rewrite for apr
make working example