Replace substr magic number with function.