fixed bug in variable allocation