Completed and tested functions