gui code separated. code working now