I fixed the problem with the help of a callback that will be activated as soon as the function ends and I won't have to do an await operation