Removed switch statement and replaced with if conditional