Fixes button behavior due to incorrect comparisson and missing nil validation.