Added some of gegys code