implemented the memory buttons, fixed logic in determining calculations