validating arrays & adding length function