added check for length