Assignment Calculator loosely based on work by damienh