wrote functionality