Updated version of #138