Merge with martins version