Problems with making a function