minor refactor of code