solve #4 problem