Incorrect usage of substring()