some code safety check and year bug fix