Added a Search Function and Fixed up the Main Function