reimplemented 'printArray' function