Made program more verbose and added out of mem check