refactoring based on Todd's comment