example code used to answer questions on stackoverflow