Several refactor, Added comment