Change unsafe functions to safe functions