renamed and put in locking after pi memory issues