Fixed minor bug where same element was added twice in the beginning. Improved readability of code