Da quello che si vede dovrebbe fungere correttamente come fai tu. Quindi l'errore è altrove ;-)