add toarray function in model