fix bug and make it runable under hadoop stream.