finalised matrix reading functions