Your problem has to be elsewhere. The code you posted looks fine.