major update: additions and refactoring