late night work. this really needs revision