Refactor and check for rbenv