minor code refactoring mainly style