Changed switch statements for compatibility