initial attempt to write function