fixed defintion of two functions