Fixed duplication issue and logic for spacing