performance, code readability and expandability improvements