updated header, added verifications to file and memory allocation