refactor + webgl compatible