finished main coding