merge with Vincent's code