Fixed an issue with length checking