refactor and add gems