polish code; try to compare var val based on type