function has now been written but not debugged