Draft of a finish product, but still needs debugging. Need to change '0' case to avoid stack error.