added some formatting. might be wrong
Needs testing!