use array_replace_recursive, luke

also fix #667
Merge pull request #677 from ivan1986/patch-1

use array_replace_recursive, luke