Simplified pivot code

Removed redundant if statements