merge local and global options first and then call the next foreach only once?