small code refactor and better structure