move functions to zsh/lib/functions and update record function