fixed possible overflow, also fixed so it split the string correct