adding in error check and fixing linked in creation