Complete code re-write
complete re-write of code