Removed unnecessary logging and fixed casting error