change functions for thread-safe