Fix type issue in functions