Updated to cast length variable to the correct type for formatting