boundary of substring function is now casted properly to integer