Added recursive conditional functionality