adapted to Mavericks