This piece of code should be integrated with the if-else chain just below for readability