use memset instead of while loop madness