functions move to Mainapp.opl