writting function documentation and fixing some problems. Debug new version in dev gspau environment