Refactored using an array to store terms