Modify some functions to return Error