cleaned code per @utkarshkukreti's suggestions