Fixed bug where output variable was not being updated correctly.