Skeleton code from Jnune's adapter