modified for GUI