Finally works, refactor and complete.