updated according to Cory's comments