changed code to get rid of Notices