refactored merge hist to pred function