Added some ifs, changed few lines from pull request.
Changed description to more logical.