Remove excessive identation and check if state is set before comparing