adds a stack S3 method