answer saving refactored