use memset() instead of slow c loops