Nhan's hacky version