Fix cast of string to array and strange code