Fixing buggs in array implementation