Code formatting and better checking if variables exist