new version with acceleration function