Implemention of #339