Extracted rendering logic and added css