works completely but still needs comments