simplified and corrected for new api"