changed amount to quantity, and bug fixes