Finished Functionlity of code: