refactoring labelsComponent function

add init and attachEvents functions. Create return.