standalone python module based on Ali's changes