Bug fix in minus function