add volatile qualifiers, add helper functions for error mechanism