Added first version
Adding second version (warning: long computation! might want to skip the last bit)