added volatile keyword for registry access