Changed switch to if statement