added method from pull request by KingFaris10. was the easiest way to
merge the changes