code improve based on zlx's advise
I think I sould pay this guy for the review