added some visual and refactored code