Completeish code... kinda garbage still