Changed code to use quantities