added code and documentation