Array based solution. Not working yet.