refactored code, integrated to phpstorm