avoided some copies and casts