Modularize some functions to functions-text