fixed bugs in array printing