rewrite load function