Updated function to deal with mixed runs