Finished functionality of basic assignment 2