begin to write final function to calc green threshold