Gh476 self contained independent reusable implementation

#476 
de ce avem nevoie de asta? nu sunt sigur e corect; probleme de perf