added test and changed to median