improved switch statment