updated code and diagram again