added ends with tests