Partially tested, working solution