writting functions according to tests