separated code/head/plot functions