maybe there is a better way of getting this substring