refactor using idioms