Now uses case and can accept pipe input