split functions to Functions.swift, remove bug