More efficient way of value checking