moved function to functions lib