correcting bugs in restaer function