Refactor code to rearrange coefficient order and add ordinal position