moving some generic array stuff in a helper