Refactor - currently not working. Need to integrate old code with new code.