Fixed bug when reading variables