update Consistent with astaxie's code