updated according to davids sugesstions