increase max l value and some error checking