wrote functions