The program halts at here if msize != 3. This function has been changed.