fixed independent function to use parallel