added code for AMA lengths