added some code (reverted from commit feafe312fd615288bfbf419bea4a8ae49ed68275)