Removed some variables that just read from getter methods and used the getter methods directly in the code to avoid any potential issues with null pointers.