@3oheme refactor and created a couple of functions, but I still dont get it