added *ptr and if() instead just if()