Fixed bug with incorrect variable