added support for foreign arrays