Variable conditional not working correctly.