move ZAMS calculation out of plot function