somewhat solution for f(4)