Refactor code

Do a little bit change right, may take as reference only