make it more efficient and short.
fix bug