Adapting js from pfsc...