moved rendering logic