changed from if-elsif to switch