writen functions