final solution (not working)