refactor code so it clearer now