@3oheme refactored functions, so it's easier to accept pull requests