move function to local scope
fix a typo