Modified apply_scidb to retain dimension of original array