refactored method in order to allow it to update dynamically based on params.