fix bug and rename functions