Renamed variables
Added null check