Ok! I didn't really understand the bit of code you mentioned, but it gave me another idea about how to do it, so now it works!
Thanks!