removed SLOW numpy array manipulation. Put structure format code into this script