Cleaned up code with ternary operators.  Removed unused variables