added function for triple input and output