Fixed slight bug in logic.