removed set_length and added it as a parameter