Fixed codes for PR, removed unnecessary variables