recactor code