an ok version of fixed problem 1