refactor problem5, soo much betta