modified for mavericks