Refactored functions to allow for named parameters