Added logic for setting return value