finished stack exercise, needs refactoring.