Moved rendering to a separate loop