running program ok now. But more optimization is needed!