Working (Not Beautiful looking) Code