forked version of Hcetor's