minor refactor of previous code