refactored to use associative arrays to improve readability