refactor outdated refactored solution using destructive method and one line if/else statement