Code from following newcoder,io tutorials