fix rendering multiple times bug