fixed a bug in spread function