Completed most functions