First commit. Code finished and working. Still need chain as parameter.