change functions to return 1 or -1