added mem clear back in to avoid bad results