remove trailing spaces
adding functionality to indicate the max number of tags