improve code of last commit