updated according to Daves suggestions