Fixed performance issue
Fixed npe