fully extracted from taminojs