fixed and tested functions