rewrite. now supports return statements and finally statements