Created working solution, might need bug fixes