code refactor finished. readability improved by 9000 pts