Added code for parts 1 & 2