Used a matcher instead of if else statement