added guy's functions

plus made some improvements and changes