Improve psg function
Fix calculator function