improve function to functions