credit to innoying for saving code