I forgot to update here, but I got it to work! I just had to write that piece of code separately as you said. Thanks for the help!