Added code, fully commented