Updated code reflecting changes raised by @CanIbanoglu