started writing function