fixed bad file descriptor bug and added LED flashing function