modernize code slightly