use if clause alongside assignment