Remove duplicated code
Remove duplicated code