Fix bug and rename function