Still not working. Partially refactored.