removing raw unsafe pointer manipulation where possible (using method instead)