These would be better factored out into helper functions, once implemented for f1 and once for f4.
Then also call them from init...