Completed most functions needed