modify the source codes from UFLDL