refactored some of the status code for rendering and updated template
added legend