error handling done and move code to page generator