added code, more comments