change some code more elegant