replaced substr(-1)