refactor the code, also  parse texture option explictly