added code that has been tested