refactored with more structure and added options for styling