slightly better code to avoid doing copy when not necessary