rewrote code & split into separate modules
changed template formatting