Added, debugged safe_input version