This could probably be done better, will fix later