Rewrote programme parsing functions