moved location of savefunction