forked from original, not  finished!