Fixed bug with wrong assigned variable