simplified problem4 a little