Updated version of #224