Added logic for handling output values