code fixed
refactor the method