Functions for working with 2-d array