refactored and added correct parameters
merged David's changes into my files