rewrite handle file script to version 2.0