added some style and did some refactoring