update after reviewing code on Mattans repository