added nested conditional