ptr variable needed to be declared with nullptr. also some formatting.