running median with bugs