code now properly returns the correct colour on a given position