refactoring: separate procedure for weighted median and new functions for quantile regression loss