updated according to anders suggestions